
import {
    websocket,
    createWebSocket,
    closeWebSocket
} from './websocket.js'

import React, { FC, useEffect, useState, useRef } from 'react';

export default () => {

    useEffect(() => {

        createWebSocket('ws:127.0.0.1:3030/2')

        return () => {
            closeWebSocket()
        }
    }, [])

    const sendmsg = () => {
        websocket.send("我是点击发送的消息")
    }

    return <div>我是demo
        <button onClick={sendmsg}>点我给后端发消息</button>
    </div>
}